﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter20
{
    using Chapter20.View;
    using Chapter20.ViewModel;

    /// <summary>
    /// 第20章 格式化绑定的数据
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 数据绑定回顾
            #endregion

            #region 02 数据转换
            /*
             * 01 使用 StringFormat 属性
             * 02 值转换器简介
             * 03 使用值转换器设置字符串的格式
             * 04 应用条件格式化
             * 05 评估多个属性
             * */
            #endregion

            #region 03 列表控件
            #endregion

            #region 04 列表样式
            /*
             * 01 ItemContainerStyle
             * 02 包含复选框或单选框按钮的 ListBox 控件
             * 03 交替条目样式
             * 04 样式选择器
             * */
            #endregion

            #region 05 数据模板
            /*
             * 01 分离和重用模板
             * 02 使用更高级的模板
             * 03 改变样板
             * 04 模板选择器
             * 05 模板与选择
             * 06 改变项的布局
             * */
            #endregion

            #region 06 ComboBox 控件
            #endregion

            #region 07 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                if ((Button)e.Source == button1)
                {
                    Demo(new BindingWindow());
                }
                if ((Button)e.Source == button2)
                {
                    Demo(new StringFormatWindow());
                }
                if ((Button)e.Source == button3)
                {
                    Demo(new ConverterWindow());
                }
                if ((Button)e.Source == button4)
                {
                    Demo(new ImageConverterWindow());
                }
                if ((Button)e.Source == button5)
                {
                    Demo(new BrushConverterWindow());
                }
                if ((Button)e.Source == button6)
                {
                    Demo(new MultiBindingWindow());
                }
                if ((Button)e.Source == button7)
                {
                    Demo(new MultiValueConverterWindow());
                }
                if ((Button)e.Source == button8)
                {
                    Demo(new ItemsContainerStyleWindow());
                }
                if ((Button)e.Source == button9)
                {
                    Demo(new ItemsRadioButtonWindow());
                }
                if ((Button)e.Source == button10)
                {
                    Demo(new ItemsCheckBoxWindow());
                }
                if ((Button)e.Source == button11)
                {
                    Demo(new ItemsAlternationWindow());
                }
                if ((Button)e.Source == button12)
                {
                    Demo(new ItemsStyleSelectorWindow());
                }
                if ((Button)e.Source == button13)
                {
                    Demo(new ItemsDataTemplateWindow());
                }
                if ((Button)e.Source == button14)
                {
                    Demo(new ItemsAdvDataTemplateWindow());
                }
                if ((Button)e.Source == button15)
                {
                    Demo(new CategoryWindow());
                }
                if ((Button)e.Source == button16)
                {
                    Demo(new ItemsTriggersWindow());
                }
                if ((Button)e.Source == button17)
                {
                    Demo(new ItemsTemplateSelectorWindow());
                }
                if ((Button)e.Source == button18)
                {
                    Demo(new ItemsTriggers2Window());
                }
                if ((Button)e.Source == button19)
                {
                    Demo(new ItemsDataTriggerWindow());
                }
                if ((Button)e.Source == button20)
                {
                    Demo(new ItemsPanelTemplateWindow());
                }
                if ((Button)e.Source == button21)
                {
                    Demo(new ItemsComboBoxWindow());
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
